package com.hsyt.pms.sys.dubbo.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hsyt.pfc.support.rpc.PageResult;
import com.hsyt.pms.api.dto.system.SysCityDto;
import com.hsyt.pms.api.vo.system.SysCityVo;
import com.hsyt.pms.orm.sys.SysCityDao;
import com.hsyt.pms.sys.dubbo.SysUserService;
import com.hsyt.pms.sys.dubbo.SysCityService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.alibaba.dubbo.config.annotation.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName: SysCityServiceImpl
 * @Description: TODO
 * @author wangze@hsyuntai.com
 * @date 2019年2月12日 下午2:45:51
 */
@Slf4j
@Component
@Service(version = "0.0.1", interfaceClass = SysCityService.class, registry = "pms", group = "pmsSystem", timeout = 3000)
public class SysCityServiceImpl implements SysCityService {

    private static final Logger LOGGER = LoggerFactory.getLogger(SysCityServiceImpl.class);

    @Resource
    private SysCityDao sysCityDao;

    @Override
    public int updateByPrimaryKey(SysCityDto sysCityDto) {
        return sysCityDao.updateByPrimaryKey(sysCityDto);
    }

    @Override
    public int insertSysCity(SysCityDto sysCityDto) {
        return sysCityDao.insertSysCity(sysCityDto);
    }

    @Override
    public List<SysCityDto> listCity(SysCityDto sysCityDto) {
        return sysCityDao.listCity(sysCityDto);
    }

    @Override
    public PageResult<SysCityVo> searchPageDataByDto(SysCityDto dto) {
        Page<?> page = PageHelper.startPage(dto.getPageNumber(), dto.getPageSize(), true);
        List<SysCityVo> list = sysCityDao.queryCityByDto(dto);
        PageResult<SysCityVo> pageResult = PageResult.create(page.getTotal(), list);
        return pageResult;
    }

}
